package com.rao.crm.dao.impl;

import com.rao.crm.dao.UserDao;
import com.rao.crm.domain.User;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

/**
 * @author Srao
 * @version 1.0
 * @className UserDaoImpl
 * @date 2019/9/18 19:29
 * @package com.rao.crm.dao.impl
 * @description
 */
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {


    @Override
    public void regist(User user) {
        this.getHibernateTemplate().save(user);
    }

    @Override
    public User login(User user) {
        List<User> list = (List<User>) this.getHibernateTemplate().find("from User where user_code=? and user_password=?", user.getUser_code(), user.getUser_password());
        if (list.size() > 0){
            return list.get(0);
        }else {
            return null;
        }
    }
}
